<%
=begin
apps: rabbitmq
platforms: kubernetes, tanzu-application-catalog
id: load_files
title: Load custom definitions
category: configuration
weight: 20
=end %>

It is possible to [load a RabbitMQ definitions file to configure RabbitMQ](https://www.rabbitmq.com/management.html#load-definitions). Follow the steps below:

* Store the JSON as a [Kubernetes secret](https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-files-from-a-pod), because definitions may contain RabbitMQ credentials. Within the secret's data, choose a key name that corresponds with the desired load definitions filename (such as *load_definition.json*) and use the JSON object as the value.

  Here is an example of one such secret:

~~~
apiVersion: v1
kind: Secret
metadata:
  name: rabbitmq-load-definition
type: Opaque
stringData:
  load_definition.json: |-
    {
      "users": [
        {
          "name": "user",
          "password": "CHANGEME",
          "tags": "administrator"
        }
      ],
      "vhosts": [
        {
          "name": "/"
        }
      ]
    }
~~~

 * Specify the *management.load_definitions* property as an *extraConfiguration* pointing to the load definition file path within the container (for example, */app/load_definition.json*) and set the *loadDefinition.enable* chart parameter to *true*.

Any load definitions specified become available within the container at */app*.

> NOTE: Loading a definition will take precedence over any configuration done through [Helm values](https://github.com/bitnami/charts/tree/master/bitnami/rabbitmq#parameters).

If needed, use *extraSecrets* to let the chart create the secret. With this approach, there is no need to manually create it before deploying a release. These secrets can also be templated to use supplied chart values. Here is an example:

~~~
auth:
  password: CHANGEME
extraSecrets:
  load-definition:
    load_definition.json: |
      {
        "users": [
          {
            "name": "{{ .Values.auth.username }}",
            "password": "{{ .Values.auth.password }}",
            "tags": "administrator"
          }
        ],
        "vhosts": [
          {
            "name": "/"
          }
        ]
      }
loadDefinition:
  enabled: true
  existingSecret: load-definition
extraConfiguration: |
  load_definitions = /app/load_definition.json
~~~
